In Starlogo, collisions are where agents collide or run into each other. Upon these "collisions" various actions take place ranging from agents "dying", score increases, and other changes to the program's behavior.

In this activity, the students will create a game where they control a "Hero" to collect "Treasure rings" while avoiding moving "Bad Guys". The students have the option to name the agents as they deem appropriate. The "Bad Guys" are not a group of different agents but the same agent being used multiple times.



Multi Agents (Hero, Bad Guys, and Treasure Rings) with Collisions.

We will produce a game where you control an agent (Hero) to evade Bad Guys and gather Treasure. If you run into a Bad Guy (Collision), you will die. If you run into a Treasure Ring (Collision), you will gain points. The game runs for a set time limit.

1) Create your Hero, Bad Guy, and Treasure.

2) You will be creating a normal Setup but using <create do> blocks for your agents. Besides providing number of agents, you will be able to <set color>, <set size>, <model skin off) [Blue Traits Drawer], <set agent camera>, and <over shoulder> [Yellow Controls Drawer] for your agents. The <score> blocks are found in the [Dark Red Setup Drawer] also. Remember <create do> blocks for your agents are found only in My Blocks.


external image z8u21IdWeDH6GUE86OPKBymTuECjadeyLYkBI0btxeqagTFZRmTL8eoV2syYC7FUr8D2ztdO66ab43gRuLZoK1dqzOrJFrURqt5ceke7cVHyWELvV_w

3) The <run> block will allow the program to run for a specific amount of time. The block starts with a section for seconds. There are sections for each agent underneath.
The <if test then> blocks found in [Orange Logic Drawer].
The Movement blocks are found in the [Red Movement Drawer].
Keyboard Controls are found in [Yellow Controls Drawer].
The <yield> block is found in [Orange Logic Drawer] to provide a pause in movements.

The Hero moves as you want. The Bad Guys move forward and bounce off walls. The Treasure Rings spin in place.

external image fvrB-gTlRD71Y7sPgy4y8SSXrjPZ7m3LnvlCh5FEJ2m2DFp8i3I40okW-0PmFaDuA0GA-x6gkUDc_Z3w24YzQXyF9NNmGyBqdu80DrZgrHyY_shKSCk


4) Collisions blocks are found in My Blocks (to the left of Factory Blocks).

In it, you describe the actions of agents bumping into (colliding) with each other. Grab two collision blocks for Bad Guys-Hero and Hero-Treasure Rings.

When the Bad Guys collide with the Hero, the Hero dies with the sound of breaking glass and the Bad Guys saying something.

When the Hero collides with a Treasure Ring, the Treasure Ring disappears with a laugh sound and the Hero’s score increases by 1.

The <die> blocks are found in [Orange Logic Drawer] to kill agents.
The <play sound> and <glass> blocks are found in the [Green Sound Drawer].
The <say> and <text> blocks are found in the {Light Blue Text Drawer]
The <inc score> block is found in the [Dark Red Setup Drawer].

external image -Glkb4NzSuby9XVQUWYM6imqQJaVJrcjAqhDpDwcNtQZI8kMbtAuTNQTkquQOojYbLIkbMAKNesX_tr6uAKiQfk7yUfg5IYW98ABrxl-Ww19wIS9gXI